<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.42">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #bb0e03}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #bf0000}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #000000}
span.s1 {color: #000ebe}
span.s2 {color: #606060}
span.s3 {color: #167209}
span.s4 {color: #bb0e03}
span.s5 {color: #000000}
span.s6 {color: #0000bf}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><b>MeanTriggered<span class="Apple-tab-span">	</span></b>Mean of recent values, triggered</p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="s1">MeanTriggered</span>.kr(in, trig, length, mul, add)</p>
<p class="p2"><br></p>
<p class="p4">Calculates the mean of the most recent <i>length</i> values, but only paying attention to values input while the trigger is greater than zero. One application of this is to calculate a running mean of values coming from FFT analysis.</p>
<p class="p5"><br></p>
<p class="p4">While trig&lt;=0, the last-measured mean is held constant.</p>
<p class="p5"><br></p>
<p class="p4">The <i>length</i> argument is set at initialisation, and cannot be modulated. The length is directly reflected in the amount of real-time memory taken by this UGen, so please think carefully before using large values of <i>length</i>. Values in the low single- or double-figures are expected.</p>
<p class="p5"><br></p>
<p class="p5"><br></p>
<p class="p4"><b>Examples</b></p>
<p class="p5"><br></p>
<p class="p6">s.boot;</p>
<p class="p7">// Simple polling of mean values - you could do this without a UGen!</p>
<p class="p6">x = {<span class="s1">|val=1, t_trig=0|</span> <span class="s1">MeanTriggered</span>.kr(val, t_trig, 3).poll(t_trig, <span class="s2">"Mean of recent 3 values"</span>); }.play;</p>
<p class="p6">x.set(<span class="s3">\val</span>, 10.rand.postln, <span class="s3">\t_trig</span>, 1); <span class="s4">// Execute this repeatedly</span></p>
<p class="p8"><br></p>
<p class="p6">x.free;</p>
<p class="p8"><br></p>
<p class="p7">// Using it as an audio filter - compare the sounds of these:</p>
<p class="p6">x = {<span class="s1">WhiteNoise</span>.ar(0.1)}.play;</p>
<p class="p6">x.free;</p>
<p class="p9"><span class="s5">x = {</span><span class="s6">MeanTriggered</span><span class="s5">.ar(</span><span class="s6">WhiteNoise</span><span class="s5">.ar(0.1), 1, 3)}.play; </span>// Note that ".sum" would be more efficient here...</p>
<p class="p10">x.free;</p>
<p class="p9"><span class="s5">x = {</span><span class="s6">MeanTriggered</span><span class="s5">.ar(</span><span class="s6">WhiteNoise</span><span class="s5">.ar(0.1), 1, 11)}.play; </span>// Note that ".sum" would be more efficient here...</p>
<p class="p10">x.free;</p>
</body>
</html>
